Skip to content

Conversation

@Rentacookie
Copy link
Contributor

@Rentacookie Rentacookie commented Nov 26, 2025

Introduce SQL Server / Azure SQL Database as a replication datasource

This change set enables PowerSync to listen for changes on SQL Server Databases that have Change Data Capture (CDC) enabled.

This is achieved by polling the CDC tables for updates on a regular interval and writing the changes to the bucket storage. For more details on how CDC works please see documentation:
CDC for SQL Server
CDC for Azure SQL Database

Requirements:

  1. CDC enabled SQL Server database
  2. _powersync_checkpoints table to allow PowerSync to generate regular updates. Table should be CDC enabled.
  3. CDC enabled on all the tables PowerSync needs to replicate.
  4. Database user with the following:
    • Read / Write permissions on the PowerSync checkpoints table.
    • Read permissions on the replicated tables
    • cdc_reader role which grants access to CDC tables and functions
    • VIEW SERVER PERFORMANCE STATE (SQL Server only)
    • VIEW DATABASE PERFORMANCE STATE (SQL Server and Azure SQL)

See init.sql for examples.

Self Hosted Demo available here:

More module templating
- MSSQL Connection manager
- Various utils for db querying
- Added schema utils
More module template files added
Added type mapping tests
@Rentacookie Rentacookie marked this pull request as ready for review December 2, 2025 18:31
Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to review the replication implementation, but here are some initial comments.

Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall architecture looks good. My main comments here are around SQL injection possibilities, primarily with the table and schema names.

@Rentacookie Rentacookie merged commit b77bb2c into main Dec 4, 2025
25 checks passed
@Rentacookie Rentacookie deleted the feature/mssql-replication branch December 4, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants